import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { visualizer } from 'rollup-plugin-visualizer'
import { viteExternalsPlugin } from 'vite-plugin-externals'
import { createHtmlPlugin } from 'vite-plugin-html'

// https://vite.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    createHtmlPlugin({
      inject: {
        data: {
          title: '后台管理系统',
          injectScript: `
          <script src="https://cdn.jsdelivr.net/npm/vue@3.5.18/dist/vue.global.min.js"></script>
          <script src="https://cdn.jsdelivr.net/npm/echarts@5.6.0/dist/echarts.min.js"></script>
          <script src="https://cdn.jsdelivr.net/npm/element-plus@2.10.4/dist/index.full.min.js"></script>
          <script src="https://cdn.jsdelivr.net/npm/quill@2.0.3/dist/quill.min.js"></script>
          <script src="https://cdn.jsdelivr.net/npm/@element-plus/icons-vue@2.3.1/dist/index.iife.min.js"></script>`
        }
      }
    }),
    visualizer(),
    viteExternalsPlugin({
      vue: 'Vue',
      echarts: 'echarts',
      'element-plus': 'ElementPlus',
      quill: 'Quill',
      '@element-plus/icons-vue': 'ElementPlusIconsVue'
    })
  ]
})
